package com.pwser.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pwser.ehcache.User;
import com.pwser.ehcache.UserService;

@RestController
@RequestMapping("/ec")
public class EhcacheController {
	@Autowired
	private UserService userService;
	
	@RequestMapping("/select")
	public String select(String id) {
		User user = userService.findByUserId(id);
		System.err.println("#####查询结果#####" + user.getUserName());
		return "success";
	}
	
	@RequestMapping("/update")
	public String update() {
		User user = new User();
		user.setUserId(1000);
		user.setUserName("更新后的姓名值");
		userService.update(user);
		return "success";
	}
	
	@RequestMapping("/delete")
	public String delete(String id) {
		userService.delete(id);
		return "success";
	}
	
	@RequestMapping("/save")
	public String save() {
		User user = new User();
		user.setUserId(9999);
		user.setUserName("bbb");
		userService.save(user);
		return "success";
	}

}
